home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / SoundInput.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  11KB  |  281 lines

  1. /*
  2.      File:        SoundInput.h
  3.  
  4.      Contains:    Sound Input Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __SOUNDINPUT__
  19. #define __SOUNDINPUT__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __APPLEEVENTS__
  25. #include <AppleEvents.h>
  26. #endif
  27. #ifndef __WINDOWS__
  28. #include <Windows.h>
  29. #endif
  30. #ifndef __DIALOGS__
  31. #include <Dialogs.h>
  32. #endif
  33. #ifndef __FILES__
  34. #include <Files.h>
  35. #endif
  36. #ifndef __SOUND__
  37. #include <Sound.h>
  38. #endif
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. #if PRAGMA_IMPORT_SUPPORTED
  45. #pragma import on
  46. #endif
  47.  
  48. #if PRAGMA_ALIGN_SUPPORTED
  49. #pragma options align=mac68k
  50. #endif
  51.  
  52. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  53. /*
  54.                         * * *  N O T E  * * *
  55.  
  56.     This file has been updated to include Sound Input Manager 1.1 interfaces.
  57.  
  58.     Some of the Sound Input Manager 1.1 interfaces were not put into the InterfaceLib
  59.     that originally shipped with the PowerMacs. These missing functions and the
  60.     new 1.1 interfaces have been released in the SoundLib library for PowerPC
  61.     developers to link with. The runtime library for these functions are
  62.     installed by Sound Manager 3.2. The following functions are found in SoundLib.
  63.  
  64.         ParseAIFFHeader(), ParseSndHeader()
  65.  
  66. */
  67.  
  68. enum {
  69.     siDeviceIsConnected            = 1,                            /*input device is connected and ready for input*/
  70.     siDeviceNotConnected        = 0,                            /*input device is not connected*/
  71.     siDontKnowIfConnected        = -1,                            /*can't tell if input device is connected*/
  72.     siReadPermission            = 0,                            /*permission passed to SPBOpenDevice*/
  73.     siWritePermission            = 1                                /*permission passed to SPBOpenDevice*/
  74. };
  75.  
  76.  
  77. enum {
  78.                                                                 /*Info Selectors for Sound Input Drivers*/
  79.     siActiveChannels            = 'chac',                        /*active channels*/
  80.     siActiveLevels                = 'lmac',                        /*active meter levels*/
  81.     siAGCOnOff                    = 'agc ',                        /*automatic gain control state*/
  82.     siAsync                        = 'asyn',                        /*asynchronous capability*/
  83.     siChannelAvailable            = 'chav',                        /*number of channels available*/
  84.     siCompressionAvailable        = 'cmav',                        /*compression types available*/
  85.     siCompressionFactor            = 'cmfa',                        /*current compression factor*/
  86.     siCompressionHeader            = 'cmhd',                        /*return compression header*/
  87.     siCompressionNames            = 'cnam',                        /*compression type names available*/
  88.     siCompressionType            = 'comp',                        /*current compression type*/
  89.     siContinuous                = 'cont',                        /*continous recording*/
  90.     siDeviceBufferInfo            = 'dbin',                        /*size of interrupt buffer*/
  91.     siDeviceConnected            = 'dcon',                        /*input device connection status*/
  92.     siDeviceIcon                = 'icon',                        /*input device icon*/
  93.     siDeviceName                = 'name',                        /*input device name*/
  94.     siHardwareBusy                = 'hwbs',                        /*sound hardware is in use*/
  95.     siInputGain                    = 'gain',                        /*input gain*/
  96.     siInputSource                = 'sour',                        /*input source selector*/
  97.     siInputSourceNames            = 'snam',                        /*input source names*/
  98.     siLevelMeterOnOff            = 'lmet',                        /*level meter state*/
  99.     siModemGain                    = 'mgai',                        /*modem input gain*/
  100.     siNumberChannels            = 'chan',                        /*current number of channels*/
  101.     siOptionsDialog                = 'optd',                        /*display options dialog*/
  102.     siPlayThruOnOff                = 'plth',                        /*playthrough state*/
  103.     siRecordingQuality            = 'qual',                        /*recording quality*/
  104.     siSampleRate                = 'srat',                        /*current sample rate*/
  105.     siSampleRateAvailable        = 'srav',                        /*sample rates available*/
  106.     siSampleSize                = 'ssiz',                        /*current sample size*/
  107.     siSampleSizeAvailable        = 'ssav',                        /*sample sizes available*/
  108.     siSetupCDAudio                = 'sucd',                        /*setup sound hardware for CD audio*/
  109.     siSetupModemAudio            = 'sumd',                        /*setup sound hardware for modem audio*/
  110.     siStereoInputGain            = 'sgai',                        /*stereo input gain*/
  111.     siTwosComplementOnOff        = 'twos',                        /*two's complement state*/
  112.     siVoxRecordInfo                = 'voxr',                        /*VOX record parameters*/
  113.     siVoxStopInfo                = 'voxs',                        /*VOX stop parameters*/
  114.     siCloseDriver                = 'clos',                        /*reserved for internal use only*/
  115.     siInitializeDriver            = 'init',                        /*reserved for internal use only*/
  116.     siPauseRecording            = 'paus',                        /*reserved for internal use only*/
  117.     siUserInterruptProc            = 'user',                        /*reserved for internal use only*/
  118.                                                                 /*Qualities*/
  119.     siCDQuality                    = 'cd  ',                        /*44.1kHz, stereo, 16 bit*/
  120.     siBestQuality                = 'best',                        /*22kHz, mono, 8 bit*/
  121.     siBetterQuality                = 'betr',                        /*22kHz, mono, MACE 3:1*/
  122.     siGoodQuality                = 'good'                        /*22kHz, mono, MACE 6:1*/
  123. };
  124.  
  125. typedef struct SPB SPB;
  126. typedef SPB *SPBPtr;
  127. /*user procedures called by sound input routines*/
  128. /*
  129.         This ProcPtr uses register based parameters on the 68k and cannot
  130.         be written in or called from a high-level language without the help of
  131.         mixed mode or assembly glue.
  132.  
  133.             typedef pascal void (*SIInterruptProcPtr)(SPBPtr inParamPtr, Ptr dataBuffer, short peakAmplitude, long sampleSize);
  134.  
  135. */
  136. typedef pascal void (*SICompletionProcPtr)(SPBPtr inParamPtr);
  137.  
  138. #if GENERATINGCFM
  139. typedef UniversalProcPtr SIInterruptUPP;
  140. typedef UniversalProcPtr SICompletionUPP;
  141. #else
  142. typedef Register68kProcPtr SIInterruptUPP;
  143. typedef SICompletionProcPtr SICompletionUPP;
  144. #endif
  145. /*Sound Input Parameter Block*/
  146. struct SPB {
  147.     long                             inRefNum;                    /*reference number of sound input device*/
  148.     unsigned long                     count;                        /*number of bytes to record*/
  149.     unsigned long                     milliseconds;                /*number of milliseconds to record*/
  150.     unsigned long                     bufferLength;                /*length of buffer in bytes*/
  151.     Ptr                             bufferPtr;                    /*buffer to store sound data in*/
  152.     SICompletionUPP                 completionRoutine;            /*completion routine*/
  153.     SIInterruptUPP                     interruptRoutine;            /*interrupt routine*/
  154.     long                             userLong;                    /*user-defined field*/
  155.     OSErr                             error;                        /*error*/
  156.     long                             unused1;                    /*reserved - must be zero*/
  157. };
  158.  
  159.  
  160.  
  161. extern pascal NumVersion SPBVersion(void )
  162.  FOURWORDINLINE(0x203C, 0x0000, 0x0014, 0xA800);
  163.  
  164. extern pascal OSErr SndRecord(ModalFilterUPP filterProc, Point corner, OSType quality, SndListHandle *sndHandle)
  165.  FOURWORDINLINE(0x203C, 0x0804, 0x0014, 0xA800);
  166.  
  167. extern pascal OSErr SndRecordToFile(ModalFilterUPP filterProc, Point corner, OSType quality, short fRefNum)
  168.  FOURWORDINLINE(0x203C, 0x0708, 0x0014, 0xA800);
  169.  
  170. extern pascal OSErr SPBSignInDevice(short deviceRefNum, ConstStr255Param deviceName)
  171.  FOURWORDINLINE(0x203C, 0x030C, 0x0014, 0xA800);
  172.  
  173. extern pascal OSErr SPBSignOutDevice(short deviceRefNum)
  174.  FOURWORDINLINE(0x203C, 0x0110, 0x0014, 0xA800);
  175.  
  176. extern pascal OSErr SPBGetIndexedDevice(short count, Str255 deviceName, Handle *deviceIconHandle)
  177.  FOURWORDINLINE(0x203C, 0x0514, 0x0014, 0xA800);
  178.  
  179. extern pascal OSErr SPBOpenDevice(ConstStr255Param deviceName, short permission, long *inRefNum)
  180.  FOURWORDINLINE(0x203C, 0x0518, 0x0014, 0xA800);
  181.  
  182. extern pascal OSErr SPBCloseDevice(long inRefNum)
  183.  FOURWORDINLINE(0x203C, 0x021C, 0x0014, 0xA800);
  184.  
  185. extern pascal OSErr SPBRecord(SPBPtr inParamPtr, Boolean asynchFlag)
  186.  FOURWORDINLINE(0x203C, 0x0320, 0x0014, 0xA800);
  187.  
  188. extern pascal OSErr SPBRecordToFile(short fRefNum, SPBPtr inParamPtr, Boolean asynchFlag)
  189.  FOURWORDINLINE(0x203C, 0x0424, 0x0014, 0xA800);
  190.  
  191. extern pascal OSErr SPBPauseRecording(long inRefNum)
  192.  FOURWORDINLINE(0x203C, 0x0228, 0x0014, 0xA800);
  193.  
  194. extern pascal OSErr SPBResumeRecording(long inRefNum)
  195.  FOURWORDINLINE(0x203C, 0x022C, 0x0014, 0xA800);
  196.  
  197. extern pascal OSErr SPBStopRecording(long inRefNum)
  198.  FOURWORDINLINE(0x203C, 0x0230, 0x0014, 0xA800);
  199.  
  200. extern pascal OSErr SPBGetRecordingStatus(long inRefNum, short *recordingStatus, short *meterLevel, unsigned long *totalSamplesToRecord, unsigned long *numberOfSamplesRecorded, unsigned long *totalMsecsToRecord, unsigned long *numberOfMsecsRecorded)
  201.  FOURWORDINLINE(0x203C, 0x0E34, 0x0014, 0xA800);
  202.  
  203. extern pascal OSErr SPBGetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  204.  FOURWORDINLINE(0x203C, 0x0638, 0x0014, 0xA800);
  205.  
  206. extern pascal OSErr SPBSetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  207.  FOURWORDINLINE(0x203C, 0x063C, 0x0014, 0xA800);
  208.  
  209. extern pascal OSErr SPBMillisecondsToBytes(long inRefNum, long *milliseconds)
  210.  FOURWORDINLINE(0x203C, 0x0440, 0x0014, 0xA800);
  211.  
  212. extern pascal OSErr SPBBytesToMilliseconds(long inRefNum, long *byteCount)
  213.  FOURWORDINLINE(0x203C, 0x0444, 0x0014, 0xA800);
  214.  
  215. extern pascal OSErr SetupSndHeader(SndListHandle sndHandle, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, short baseNote, unsigned long numBytes, short *headerLen)
  216.  FOURWORDINLINE(0x203C, 0x0D48, 0x0014, 0xA800);
  217.  
  218. extern pascal OSErr SetupAIFFHeader(short fRefNum, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, unsigned long numBytes, unsigned long numFrames)
  219.  FOURWORDINLINE(0x203C, 0x0B4C, 0x0014, 0xA800);
  220.  
  221.  
  222.  
  223. /* Sound Input Manager 1.1 and later calls */
  224. extern pascal OSErr ParseAIFFHeader(short fRefNum, SoundComponentData *sndInfo, unsigned long *numFrames, unsigned long *dataOffset)
  225.  FOURWORDINLINE(0x203C, 0x0758, 0x0014, 0xA800);
  226.  
  227. extern pascal OSErr ParseSndHeader(SndListHandle sndHandle, SoundComponentData *sndInfo, unsigned long *numFrames, unsigned long *dataOffset)
  228.  FOURWORDINLINE(0x203C, 0x085C, 0x0014, 0xA800);
  229.  
  230.  
  231.  
  232.  
  233. enum {
  234.     uppSIInterruptProcInfo = kRegisterBased
  235.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(SPBPtr)))
  236.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterA1, SIZE_CODE(sizeof(Ptr)))
  237.          | REGISTER_ROUTINE_PARAMETER(3, kRegisterD0, SIZE_CODE(sizeof(short)))
  238.          | REGISTER_ROUTINE_PARAMETER(4, kRegisterD1, SIZE_CODE(sizeof(long))),
  239.     uppSICompletionProcInfo = kPascalStackBased
  240.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SPBPtr)))
  241. };
  242.  
  243. #if GENERATINGCFM
  244. #define NewSIInterruptProc(userRoutine)        \
  245.         (SIInterruptUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIInterruptProcInfo, GetCurrentArchitecture())
  246. #define NewSICompletionProc(userRoutine)        \
  247.         (SICompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSICompletionProcInfo, GetCurrentArchitecture())
  248. #else
  249. #define NewSIInterruptProc(userRoutine)        \
  250.         ((SIInterruptUPP) (userRoutine))
  251. #define NewSICompletionProc(userRoutine)        \
  252.         ((SICompletionUPP) (userRoutine))
  253. #endif
  254.  
  255. #if GENERATINGCFM
  256. #define CallSIInterruptProc(userRoutine, inParamPtr, dataBuffer, peakAmplitude, sampleSize)        \
  257.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSIInterruptProcInfo, (inParamPtr), (dataBuffer), (peakAmplitude), (sampleSize))
  258. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  259.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSICompletionProcInfo, (inParamPtr))
  260. #else
  261. /* (*SIInterruptUPP) cannot be called from a high-level language without the Mixed Mode Manager */
  262. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  263.         (*(userRoutine))((inParamPtr))
  264. #endif
  265. #endif
  266.  
  267. #if PRAGMA_ALIGN_SUPPORTED
  268. #pragma options align=reset
  269. #endif
  270.  
  271. #if PRAGMA_IMPORT_SUPPORTED
  272. #pragma import off
  273. #endif
  274.  
  275. #ifdef __cplusplus
  276. }
  277. #endif
  278.  
  279. #endif /* __SOUNDINPUT__ */
  280.  
  281.